package com.example.yoho.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import com.example.yoho.mvp.view.activity.App;
/***
 *网络状态判断工具
 */

public class NetWorkUtils {

    public static boolean isNetWork(){
        ConnectivityManager service = (ConnectivityManager) App.getInstance().getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo info;
        //wifi
        info=service.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if (info.getState()==NetworkInfo.State.CONNECTED){
            return true;
        }
        //移动网络
        info=service.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
        if (info.getState()==NetworkInfo.State.CONNECTED){
            return true;
        }
        return false;
    }
}
